<?
	if (!defined('i-Teck_ADMIN')) die("Hacking attempt");
//session_start();
$_SESSION['file_slide1']="";
	switch($mod){
		case "add":			
			//session_start();
			
		?>

   		<article class="module width_full">
			<header><h3>Thêm sản phẩm</h3></header>
<form name="f1" method="post" action="">

				<div class="module_content">		
					<fieldset>
							<label>Tên sản phẩm</label>
						    <input name="ten" type="text" id="ten" size="50" />
					</fieldset>
					<fieldset>
							<label>Tiêu đề comments</label>
						    <input name="tieudecomment" type="text" id="tieudecomment" size="50" />
					</fieldset>
					<fieldset>
							<label>URL Comment</label>
						    <input name="urlcomment" type="text" id="urlcomment" size="50" />
					</fieldset>


					<fieldset>
							<label>Hình ảnh Trang Home</label>
						    <img name=img width="150" height="120" /><input name="hinhanh" type="text" id="hinhanh" size="5" /><br/>
							<center><input class="alt_btn" type="button" value="Chọn ảnh" onClick="window.open('?act=oldproduct&mod=chon-anh','test1','width=450,height=380');">       
							<input class="alt_btn" type="button" value="Up ảnh" onClick="window.open('?act=oldproduct&mod=up-anh','test1','width=450,height=380');">
					</center></fieldset>		

					<fieldset>
							<label>Hình ảnh Nho ben phai</label>					
					</fieldset>					
					<fieldset>
							<center><input name="anhnho" type="text" id="anhnho" size="5" /><br/>
							<hr>
					</fieldset>	
					<fieldset>
							<label>Hình ảnh Slide</label>					</fieldset>					<fieldset>
							<center><span>anh 1</span>
						    <input class="alt_btn" type="button" value="Chọn ảnh" onClick="window.open('?act=oldproduct&mod=chon-anh1','test1','width=450,height=380');">       
							<input class="alt_btn" type="button" value="Up ảnh" onClick="window.open('?act=oldproduct&mod=up-anh1','test1','width=450,height=380');">
							<img name=img width="150" height="120" /><input name="slide1" type="text" id="slide1" size="5" /><br/>
							<hr>
							<span>anh 2</span>
							<input class="alt_btn" type="button" value="Chọn ảnh" onClick="window.open('?act=oldproduct&mod=chon-anh2','test1','width=450,height=380');">       
							<input class="alt_btn" type="button" value="Up ảnh" onClick="window.open('?act=oldproduct&mod=up-anh2','test1','width=450,height=380');">
							<img name=img width="150" height="120" /><input name="slide2" type="text" id="slide2" size="5" /><br/>
							<hr>
							<span>anh 3</span>
							<input class="alt_btn" type="button" value="Chọn ảnh" onClick="window.open('?act=oldproduct&mod=chon-anh3','test1','width=450,height=380');">       
							<input class="alt_btn" type="button" value="Up ảnh" onClick="window.open('?act=oldproduct&mod=up-anh3','test1','width=450,height=380');">
							<img name=img width="150" height="120" /><input name="slide3" type="text" id="slide3" size="5" /><br/>
							<hr>
							<span>anh 4</span>
							<input class="alt_btn" type="button" value="Chọn ảnh" onClick="window.open('?act=oldproduct&mod=chon-anh4','test1','width=450,height=380');">       
							<input class="alt_btn" type="button" value="Up ảnh" onClick="window.open('?act=oldproduct&mod=up-anh4','test1','width=450,height=380');">
							<img name=img width="150" height="120" /><input name="slide4" type="text" id="slide4" size="5" /><br/>
							</center>
					</fieldset>		
				
					<fieldset>
							<label>Giá tiền (VNĐ)</label>
						    <input name="gia" type="text" id="gia" size="50" />
					</fieldset>	
					<fieldset>
							<label>Danh Mục sản phẩm</label>
						    <select name="catid" id="catid">    
								<? $result=mysql_query("select * from shop_trademarks");
									while($r=mysql_fetch_array($result)){ ?>
									<option value="<? echo $r["id"];?>"><? echo stripslashes($r["name"]);?></option>
										<? }?>
								</select>
					</fieldset>	
					<fieldset>
							<label>Khuyen Mai</label>
						    <input type="radio" name="khuyenmai" value="1" />Có  
							<input type="radio" name="khuyenmai" value="0" checked="checked"/>Không
					</fieldset>	
					<fieldset>
							<label>Noi Bat</label>
						    <input type="radio" name="noibat" value="1" />Có  
							<input type="radio" name="noibat" value="0" checked="checked"/>Không
					</fieldset>	
					<fieldset>
							<label>Trang chủ</label>
						    <input type="radio" name="trangchu" value="1" />Có  
							<input type="radio" name="trangchu" value="0" checked="checked"/>Không
					</fieldset>	
					<fieldset>
							<label>Tình trạng còn hàng</label>
						     <input type="radio" name="status" value="2"/> Còn hàng
							<input type="radio" name="status" value="1"/> Đang về
							<input type="radio" name="status" value="0"/> Tạm hết
					</fieldset>	
					<fieldset>
							<label>Chế dộ bảo hành</label>		</fieldset>					
				<fieldset>
						  <center><textarea id="baohanh" name="baohanh"></textarea>
								<script language="javascript1.2">
								 generate_wysiwyg('baohanh');
								</script></center>
					</fieldset>
					<fieldset>
							<label>Phụ Kiện</label>		</fieldset>					
				<fieldset>
						  <center><textarea id="phukien" name="phukien"></textarea>
								<script language="javascript1.2">
								 generate_wysiwyg('phukien');
								</script></center>
					</fieldset>		
					<fieldset>
							<label>Phu Kien Tuong Thich</label><br/>		</fieldset>					
				<fieldset>
						    <center><textarea id="phukientuongthich" name="phukientuongthich"></textarea>
								<script language="javascript1.2">
								 generate_wysiwyg('phukientuongthich');
								</script></center>
					</fieldset>		
					<fieldset>
							<label>Độ mới</label>	</fieldset>					
				<fieldset>
						  <center><textarea id="gioithieu" name="gioithieu"></textarea>
								<script language="javascript1.2">
								 generate_wysiwyg('gioithieu');
								</script></center>
					</fieldset>	
					<fieldset>
							<label>Thông tin thêm</label><br/>		</fieldset>					
				<fieldset>
						    <center><textarea id="thongtin" name="thongtin"></textarea>
								<script language="javascript1.2">
								 generate_wysiwyg('thongtin');
								</script></center>
					</fieldset>	
					<fieldset><center><input type="submit" name="cmd" id="cmd" value="Thêm" class="alt_btn"></center>
					</fieldset>	
		</article><!-- end of styles article -->
</form>
<?
if(isset($_POST["cmd"])=="Thêm"){
	mysql_query("INSERT INTO shop_oldproduct (ten,tieudecomment,urlcomment,hinhanh,anhnho,slide1,slide2,slide3,slide4,gia,thongtin,baohanh,phukien,phukientuongthich,gioithieu,khuyenmai,trangchu,status,noibat,catid) values 
				('".addslashes($_POST["ten"])."',
				'".addslashes($_POST["tieudecomment"])."',
				'".addslashes($_POST["urlcomment"])."',
				'".addslashes($_POST["hinhanh"])."',
				'".addslashes($_POST["anhnho"])."',
				'".addslashes($_POST["slide1"])."',
				'".addslashes($_POST["slide2"])."',
				'".addslashes($_POST["slide3"])."',
				'".addslashes($_POST["slide4"])."',
				'".addslashes($_POST["gia"])."',
				'".addslashes($_POST["thongtin"])."',
				'".addslashes($_POST["baohanh"])."',
				'".addslashes($_POST["phukien"])."',
				'".addslashes($_POST["phukientuongthich"])."',
				'".addslashes($_POST["gioithieu"])."',
				'".intval($_POST["khuyenmai"])."',
				'".intval($_POST["trangchu"])."',
				'".intval($_POST["status"])."',
				'".intval($_POST["noibat"])."',
				'".intval($_POST["catid"])."')");
	mysql_close();
	echo "<meta http-equiv='refresh' content='0; url=?act=oldproduct&mod=view&page=1'>";
	}
	break;	
	case "view":	
	?>
   		<article class="module width_full">
			<header><h3>Thêm sản phẩm</h3></header>
				<div class="tab_container">
					<div id="tab1" class="tab_content">
						<table class="tablesorter" cellspacing="0"> 
						<thead> 
						<tr> 
    					<th>ID</th> 
    					<th>Tên Sản phẩm</th> 
    					<th>Danh Mục sản phẩm</th> 
    					<th>Sửa</th>
    					<th>Xóa</th>
						</tr> 
						</thead> 
						<tbody> 
 <?
  	$result = mysql_query("select * from shop_oldproduct order by id desc");
	//$page = 0;
	$sobanghi=15; //Số thể loại hiển thị trong 1 trang
	$sotrang = ceil(mysql_num_rows($result)/$sobanghi);
	$page = intval(($_REQUEST["page"]));
	if ($page <=0 ){ $page=1;}
	if ($page>$sotrang)  {$page=$sotrang;}
	$result2=mysql_query("select * from shop_oldproduct order by id desc limit ".($page-1)*$sobanghi.",".$sobanghi);	
	while($r=mysql_fetch_array($result2)){				
  ?>
  <tr>
   <td><? echo $r["id"];?></td>
    <td><a href=?act=oldproduct&mod=edit&id=<? echo $r['id'];?>><? echo $r["ten"];?></a></td>
    <? $id=$r["catid"];
	$result1=mysql_query("select * from shop_trademarks where id=$id");
	while($r1=mysql_fetch_array($result1)){
	?>
    <td><a href=?act=category&mod=edit&id=<? echo $r1['id'];?>><? echo stripslashes($r1["name"]); }?></a></td>
   
      <td><a href=?act=oldproduct&mod=edit&id=<? echo $r['id'];?>>Sửa</a></td>
    <td><a onClick="return  confirm('Bạn có muốn xóa sản phẩm này ko');"href=?act=oldproduct&mod=delete&id=<? echo $r['id'];?>>Xóa</a></td>
  </tr>
  <? }?>
  
<div align="center">
<? showPageNavigation($page,$sotrang, '','?act=oldproduct&mod=view&page=');?> 
</center>
  

			</tbody> 
			</table></div></div>
		</article><!-- end of styles article -->
	<? break;

	case "spkm":
	
	
	?>
<h3 align="center">Sản phẩm Trang chủ</h3>

<table width="600" height="54" border="0" align="center">
  <tr class="fr_top">
    <td width="26" height="23">ID</td>
    <td width="218">Tên Sản phẩm</td>
    <td width="275">Danh Mục sản phẩm</td>
    <td width="29">Sửa</td>
    <td width="30">Xóa</td>
  </tr>
  <?
  	$result = mysql_query("select * from shop_oldproduct where khuyenmai=1 order by id desc");
	$sobanghi=15; //Số thể loại hiển thị trong 1 trang
	$sotrang = ceil(mysql_num_rows($result)/$sobanghi);
	$page = intval($_GET["page"]);
	if ($page<=0) $page=1;
	if ($page>$sotrang)  $page=$sotrang;
	$result2=mysql_query("select * from shop_oldproduct where khuyenmai=1 order by id desc limit ".($page-1)*$sobanghi.",".$sobanghi);
	
	while($r=mysql_fetch_array($result2)){
		
		
		
  ?>

  <tr>
   <td height="23" class="fr"><? echo $r["id"];?></td>
    <td class="fr"><a href=?act=oldproduct&mod=edit&id=<? echo $r['id'];?>><? echo $r["ten"];?></a></td>
    <? $id=$r["catid"];
	$result1=mysql_query("select * from shop_trademarks where id=$id");
	while($r1=mysql_fetch_array($result1)){
	?>
    <td class="fr_2"><a href=?act=category&mod=edit&id=<? echo $r1['id'];?>><? echo stripslashes($r1["name"]); }?></a></td>
   
      <td class="fr_2"><a href=?act=oldproduct&mod=edit&id=<? echo $r['id'];?>>Sửa</a></td>
    <td class="fr_2"><a onClick="return  confirm('Bạn có muốn xóa sản phẩm này ko');"href=?act=oldproduct&mod=delete&id=<? echo $r['id'];?>>Xóa</a></td>
  </tr>
  <? }?>
  
<div align="center">
<? showPageNavigation($page,$sotrang, '','?act=oldproduct&mod=spkm&page=');?> 
</center>
  
  
</table> 
	<? break;






	case "edit":
	
		$id=intval($_REQUEST["id"]);
		$result=mysql_query("select * from shop_oldproduct where id=$id");
		if(mysql_num_rows($result)<=0){echo"<center><font color=red>Chưa có dữ liệu</font</center>";}
		while($r=mysql_fetch_array($result)){ 
	?>
	

    <form name="f1" method="post" action="">
    		<article class="module width_full">
			<header><h3>Sửa sản phẩm</h3></header>
				<div class="module_content">				
				<fieldset>
							<label>Tên sản phẩm</label>
						    <input name="ten" type="text" id="ten" value="<? echo $r["ten"];?>" size="50" />
				</fieldset>		
					<fieldset>
							<label>Tiêu đề comments</label>
						    <input name="tieudecomment" type="text" id="tieudecomment" value="<? echo $r["tieudecomment"];?>" size="50" />
					</fieldset>
					<fieldset>
							<label>URL Comment</label>
						    <input name="urlcomment" type="text" id="urlcomment" value="<? echo $r["urlcomment"];?>" size="50" />
					</fieldset>			
				<fieldset>
							<label>Hình ảnh</label>
						    <img name="img" <? if($r["hinhanh"]=="") echo("src='../img/oldproduct/default.jpg'"); else echo("src='../img/oldproduct/{$r["hinhanh"]}'")?> width="150" height="120" id="img" />
							<input name="hinhanh" type="text" id="hinhanh" value="<? echo $r["hinhanh"];?>" size="30" />
							<input type="button" value="Chọn ảnh" onclick="window.open('?act=oldproduct&mod=chon-anh','test1','scrollbars=1,width=450,height=380');" />
							<input type="button" value="Up ảnh" onclick="window.open('?act=oldproduct&mod=up-anh','test1','width=450,height=380');" />
				</fieldset>				
				<fieldset>
							<label>Video</label>						   
							<input name="anhnho" type="text" id="anhnho" value="<? echo $r["anhnho"];?>" size="30" />							
				</fieldset>		
				
	<fieldset>
							<label>Hình ảnh Slide</label>					</fieldset>					<fieldset>
							<center><span>anh 1</span>
							<input name="slide1" type="text" id="slide1" value="<? echo $r["slide1"];?>" size="30" />
							<input class="alt_btn" type="button" value="Chọn ảnh" onClick="window.open('?act=oldproduct&mod=chon-anh1','test1','width=450,height=380');">       
							<input class="alt_btn" type="button" value="Up ảnh" onClick="window.open('?act=oldproduct&mod=up-anh1','test1','width=450,height=380');">
													    <img name="img" <? if($r["slide1"]=="") echo("src='../img/oldproduct/default.jpg'"); else echo("src='../img/oldproduct/{$r["slide1"]}'")?> width="150" height="120" id="img" /><br><hr>
							<span>anh 2</span>
							<input name="slide2" type="text" id="slide2" value="<? echo $r["slide2"];?>" size="30" />
							<input class="alt_btn" type="button" value="Chọn ảnh" onClick="window.open('?act=oldproduct&mod=chon-anh2','test1','width=450,height=380');">       
							<input class="alt_btn" type="button" value="Up ảnh" onClick="window.open('?act=oldproduct&mod=up-anh2','test1','width=450,height=380');">
						    <img name="img" <? if($r["slide2"]=="") echo("src='../img/oldproduct/default.jpg'"); else echo("src='../img/oldproduct/{$r["slide2"]}'")?> width="150" height="120" id="img" /><br><hr>
							<span>anh 3</span>
							<input name="slide3" type="text" id="slide3" value="<? echo $r["slide3"];?>" size="30" />
							<input class="alt_btn" type="button" value="Chọn ảnh" onClick="window.open('?act=oldproduct&mod=chon-anh3','test1','width=450,height=380');">       
							<input class="alt_btn" type="button" value="Up ảnh" onClick="window.open('?act=oldproduct&mod=up-anh3','test1','width=450,height=380');">
						    <img name="img" <? if($r["slide3"]=="") echo("src='../img/oldproduct/default.jpg'"); else echo("src='../img/oldproduct/{$r["slide3"]}'")?> width="150" height="120" id="img" /><br><hr>
							<span>anh 4</span>
							<input name="slide4" type="text" id="slide4" value="<? echo $r["slide4"];?>" size="30" />
							<input class="alt_btn" type="button" value="Chọn ảnh" onClick="window.open('?act=oldproduct&mod=chon-anh4','test1','width=450,height=380');">       
							<input class="alt_btn" type="button" value="Up ảnh" onClick="window.open('?act=oldproduct&mod=up-anh4','test1','width=450,height=380');">
						    <img name="img" <? if($r["slide4"]=="") echo("src='../img/oldproduct/default.jpg'"); else echo("src='../img/oldproduct/{$r["slide4"]}'")?> width="150" height="120" id="img" />
					</center></fieldset>
					
				<fieldset>
							<label>Giá tiền</label>
						    <input name="gia" type="text" id="gia" value="<? echo $r["gia"];?>" size="50" />
				</fieldset>						
				<fieldset>
							<label>Danh Mục sản phẩm</label>
						    <select name="catid" id="catid">      
      <? $result=mysql_query("select * from shop_trademarks");
	  $catid =  mysql_fetch_array(mysql_query("select * from shop_oldproduct where id=$id"));
	  while($r1=mysql_fetch_array($result)){ ?>
       <option value="<? echo $r1["id"];?>"<? if($r1["id"]==$catid["catid"]){echo " selected='selected'";}?>><? echo stripslashes($r1["name"]);?></option>
       <? } ?>
       

        </select>
				</fieldset>						
					<fieldset>
							<label>Khuyen Mai</label>
						     <input type="radio" name="khuyenmai" value="1" <? if($r["khuyenmai"]==1){echo 'checked="checked"';}?>/> Có
							<input type="radio" name="khuyenmai" value="0" <? if($r["khuyenmai"]==0){echo 'checked="checked"';}?>"/> Không
					</fieldset>	
					<fieldset>
							<label>Noi Bat</label>
						     <input type="radio" name="noibat" value="1" <? if($r["noibat"]==1){echo 'checked="checked"';}?>/> Có
							<input type="radio" name="noibat" value="0" <? if($r["noibat"]==0){echo 'checked="checked"';}?>"/> Không
					</fieldset>	
					<fieldset>
							<label>Trang chủ</label>
						     <input type="radio" name="trangchu" value="1" <? if($r["trangchu"]==1){echo 'checked="checked"';}?>/> Có
							<input type="radio" name="trangchu" value="0" <? if($r["trangchu"]==0){echo 'checked="checked"';}?>"/> Không
					</fieldset>	
					<fieldset>
							<label>Tình trạng có hàng</label>
						     <input type="radio" name="status" value="2" <? if($r["status"]==2){echo 'checked="checked"';}?>/> Còn hàng
							<input type="radio" name="status" value="1" <? if($r["status"]==1){echo 'checked="checked"';}?>"/> Đang về
							<input type="radio" name="status" value="0" <? if($r["status"]==0){echo 'checked="checked"';}?>"/> Tạm hết
					</fieldset>	
					<fieldset>
							<label>Chế dộ bảo hành</label>		</fieldset>					
				<fieldset>
						  <center><textarea id="baohanh" name="baohanh"><? echo stripslashes($r["baohanh"]);?></textarea>
								<script language="javascript1.2">
								 generate_wysiwyg('baohanh');
								</script></center>
					</fieldset>
					<fieldset>
							<label>Phụ Kiện</label>		</fieldset>					
				<fieldset>
						  <center><textarea id="phukien" name="phukien"><? echo stripslashes($r["phukien"]);?></textarea>
								<script language="javascript1.2">
								 generate_wysiwyg('phukien');
								</script></center>
					</fieldset>	

					<fieldset>
							<label>Phu Kien Tuong Thich</label><br/>		</fieldset>					
				<fieldset>
						    <center><textarea id="phukientuongthich" name="phukientuongthich"><? echo stripslashes($r["phukientuongthich"]);?></textarea>
								<script language="javascript1.2">
								 generate_wysiwyg('phukientuongthich');
								</script></center>
					</fieldset>		
				<fieldset>
							<label>Độ mới</label>		</fieldset>					
				<fieldset>
						  <center><textarea id="gioithieu" name="gioithieu"><? echo stripslashes($r["gioithieu"]);?></textarea>
								<script language="javascript1.2">
								 generate_wysiwyg('gioithieu');
								</script></center>
				</fieldset>					
				<fieldset>
							<label>Thông tin thêm</label>		</fieldset>					
				<fieldset>
			<center>			    <textarea name="thongtin" cols="60" id="thongtin">
<? echo stripslashes($r["thongtin"]);?>


</textarea>
<script language="javascript1.2">
  generate_wysiwyg('thongtin');
</script></center>
				</fieldset>				
				<fieldset>
							<center><input type="submit" name="cmd" id="cmd" value="Sửa" class="alt_btn"></center>
				</fieldset>	</div>
		</article><!-- end of styles article -->
</form>
<? } if(isset($_REQUEST["cmd"])=="Sửa"){
		mysql_query("UPDATE shop_oldproduct SET
					ten='".addslashes($_POST["ten"])."',
					tieudecomment='".addslashes($_POST["tieudecomment"])."',
					urlcomment='".addslashes($_POST["urlcomment"])."',
					hinhanh='".addslashes($_POST["hinhanh"])."',
					anhnho='".addslashes($_POST["anhnho"])."',
					slide1='".addslashes($_POST["slide1"])."',
					slide2='".addslashes($_POST["slide2"])."',
					slide3='".addslashes($_POST["slide3"])."',
					slide4='".addslashes($_POST["slide4"])."',
					gia='".addslashes($_POST["gia"])."',
					thongtin='".addslashes($_POST["thongtin"])."',
					baohanh='".addslashes($_POST["baohanh"])."',
					phukien='".addslashes($_POST["phukien"])."',
					phukientuongthich='".addslashes($_POST["phukientuongthich"])."',
					gioithieu='".addslashes($_POST["gioithieu"])."',
					khuyenmai='".intval($_POST["khuyenmai"])."',
					trangchu='".intval($_POST["trangchu"])."',
					status='".intval($_POST["status"])."',
					noibat='".intval($_POST["noibat"])."',
					catid='".intval($_POST["catid"])."' where id=$id");
	mysql_close();
		echo "<meta http-equiv='refresh' content='0; url=?act=oldproduct&mod=view&page='>"; }
	
	break;
	
	case "delete":
		$id=intval($_GET["id"]);
		$re=mysql_query("SELECT * FROM shop_oldproduct where id=$id");
		while($r=mysql_fetch_array($re))
		{
			unlink('../img/oldproduct/'.$r["hinhanh"]);
			unlink('../img/oldproduct/'.$r["anhnho"]);
			unlink('../img/oldproduct/'.$r["slide1"]);
			unlink('../img/oldproduct/'.$r["slide2"]);
			unlink('../img/oldproduct/'.$r["slide3"]);
			unlink('../img/oldproduct/'.$r["slide4"]);
		}
		mysql_query("delete from shop_oldproduct where id=$id");
		mysql_close();
		echo "<meta http-equiv='refresh' content='0; url=?act=oldproduct&mod=view&page='>";
	break;
	
	
	case "up-anh":
	
	
?>




<form enctype="multipart/form-data" method="post">
 <div align="center">
   <h1>Upload file 
   </h1>
 </div>

 
 <table width="400" border="0" align="center" cellpadding="3" cellspacing="3">
    <tr>
      <td>Chon file 1: </td>
      <td><input name="f1" type="file" id="f1"></td>
    </tr>

	
    <tr>
      <td>&nbsp;</td>
      <td><input name="cmd" type="submit" id="cmd" value="Upload">
      <input type="reset" name="Reset" value="Reset"></td>
    </tr>
  </table>
</form> 
<?

	if ($_REQUEST["cmd"] =="Upload"){
		$a = $_FILES["f1"]["tmp_name"];
		$b = $_FILES["f1"]["name"];
		$c = $_FILES["f1"]["size"];
		$d = $_FILES["f1"]["type"];
		$e = $_FILES["f1"]["error"];
		
		 
		echo strstr("image",$d); 
		if (!getimagesize($_FILES['f1']['tmp_name']))
			{ echo "<font color=red><center>Invalid Image File...</center></font>";
			exit();
			}
			
			if (substr($d,0,5)=="image"){
				
		move_uploaded_file($a,"../img/oldproduct/".$b);
		echo "Đã upload thành công file <b>{$b}</b>!<br>Click vào ảnh để chọn file này.<br>";
		
		echo "<a title='Chọn file này' href=# onclick=\"window.opener.document.f1.hinhanh.value='$b'; window.opener.document.img.src='../img/oldproduct/$b';window.close();\"><img border=0 width=80 src=../img/oldproduct/".$b." height=60></a>";
		
 
		
		
		} else {
		echo "Upload không thành công!";
		}
	}
			break;
			
			case "chon-anh":?>
			<h1 align="center">Chọn ảnh</h1>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<? 
$a = opendir("../img/oldproduct");
$i=0;
while($f=readdir($a)){
	
	if ($f!="." && $f!=".."){
		$b = substr($f,strlen($f)-3,3);
		
		if ($b=="jpg" || $b =="jpe" || $b=="gif" || $b=="bmp"){
		if ($i==0) echo "<tr>";
		$i++;
		echo "<td><a href=# onclick=\"window.opener.document.f1.hinhanh.value='$f'; window.opener.document.img.src='../img/oldproduct/$f'; window.close();\"><img border=0 width=80 src=../img/oldproduct/".$f." title='$f'>
			</a>
		</td>";
		
		
		if ($i==2) {echo "</tr>"; $i=0;}
		}
	}
}
?>
</table><?
			break;
			
	
	
	case "up-anh1":
	
	
?>




<form enctype="multipart/form-data" method="post">
 <div align="center">
   <h1>Upload file 
   </h1>
 </div>

 
 <table width="400" border="0" align="center" cellpadding="3" cellspacing="3">
    <tr>
      <td>Chon file 1: </td>
      <td><input name="f1" type="file" id="f1"></td>
    </tr>

	
    <tr>
      <td>&nbsp;</td>
      <td><input name="cmd" type="submit" id="cmd" value="Upload">
      <input type="reset" name="Reset" value="Reset"></td>
    </tr>
  </table>
</form> 
<?

	if ($_REQUEST["cmd"] =="Upload"){
		$a = $_FILES["f1"]["tmp_name"];
		$b = $_FILES["f1"]["name"];
		$c = $_FILES["f1"]["size"];
		$d = $_FILES["f1"]["type"];
		$e = $_FILES["f1"]["error"];
		
		 
		echo strstr("image",$d); 
		if (!getimagesize($_FILES['f1']['tmp_name']))
			{ echo "<font color=red><center>Invalid Image File...</center></font>";
			exit();
			}
			
			if (substr($d,0,5)=="image"){
				
		move_uploaded_file($a,"../img/oldproduct/".$b);
		echo "Đã upload thành công file <b>{$b}</b>!<br>Click vào ảnh để chọn file này.<br>";
		
		echo "<a title='Chọn file này' href=# onclick=\"window.opener.document.f1.slide1.value='$b'; window.opener.document.img.src='../img/oldproduct/$b';window.close();\"><img border=0 width=80 src=../img/oldproduct/".$b." height=60></a>";
		
 
		
		
		} else {
		echo "Upload không thành công!";
		}
	}
			break;
			
			case "chon-anh1":?>
			<h1 align="center">Chọn ảnh</h1>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<? 
$a = opendir("../img/oldproduct");
$i=0;
while($f=readdir($a)){
	
	if ($f!="." && $f!=".."){
		$b = substr($f,strlen($f)-3,3);
		
		if ($b=="jpg" || $b =="jpe" || $b=="gif" || $b=="bmp"){
		if ($i==0) echo "<tr>";
		$i++;
		echo "<td><a href=# onclick=\"window.opener.document.f1.slide1.value='$f'; window.opener.document.img.src='../img/oldproduct/$f'; window.close();\"><img border=0 width=80 src=../img/oldproduct/".$f." title='$f'>
			</a>
		</td>";
		
		
		if ($i==2) {echo "</tr>"; $i=0;}
		}
	}
}
?>
</table><?
			break;
			
	
	
	case "up-anh2":
	
	
?>




<form enctype="multipart/form-data" method="post">
 <div align="center">
   <h1>Upload file 
   </h1>
 </div>

 
 <table width="400" border="0" align="center" cellpadding="3" cellspacing="3">
    <tr>
      <td>Chon file 1: </td>
      <td><input name="f1" type="file" id="f1"></td>
    </tr>

	
    <tr>
      <td>&nbsp;</td>
      <td><input name="cmd" type="submit" id="cmd" value="Upload">
      <input type="reset" name="Reset" value="Reset"></td>
    </tr>
  </table>
</form> 
<?

	if ($_REQUEST["cmd"] =="Upload"){
		$a = $_FILES["f1"]["tmp_name"];
		$b = $_FILES["f1"]["name"];
		$c = $_FILES["f1"]["size"];
		$d = $_FILES["f1"]["type"];
		$e = $_FILES["f1"]["error"];
		
		 
		echo strstr("image",$d); 
		if (!getimagesize($_FILES['f1']['tmp_name']))
			{ echo "<font color=red><center>Invalid Image File...</center></font>";
			exit();
			}
			
			if (substr($d,0,5)=="image"){
				
		move_uploaded_file($a,"../img/oldproduct/".$b);
		echo "Đã upload thành công file <b>{$b}</b>!<br>Click vào ảnh để chọn file này.<br>";
		
		echo "<a title='Chọn file này' href=# onclick=\"window.opener.document.f1.slide2.value='$b'; window.opener.document.img.src='../img/oldproduct/$b';window.close();\"><img border=0 width=80 src=../img/oldproduct/".$b." height=60></a>";
		
 
		
		
		} else {
		echo "Upload không thành công!";
		}
	}
			break;
			
			case "chon-anh2":?>
			<h1 align="center">Chọn ảnh</h1>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<? 
$a = opendir("../img/oldproduct");
$i=0;
while($f=readdir($a)){
	
	if ($f!="." && $f!=".."){
		$b = substr($f,strlen($f)-3,3);
		
		if ($b=="jpg" || $b =="jpe" || $b=="gif" || $b=="bmp"){
		if ($i==0) echo "<tr>";
		$i++;
		echo "<td><a href=# onclick=\"window.opener.document.f1.slide2.value='$f'; window.opener.document.img.src='../img/oldproduct/$f'; window.close();\"><img border=0 width=80 src=../img/oldproduct/".$f." title='$f'>
			</a>
		</td>";
		
		
		if ($i==2) {echo "</tr>"; $i=0;}
		}
	}
}
?>
</table><?
			break;
			
	
	
	case "up-anh3":
	
	
?>




<form enctype="multipart/form-data" method="post">
 <div align="center">
   <h1>Upload file 
   </h1>
 </div>

 
 <table width="400" border="0" align="center" cellpadding="3" cellspacing="3">
    <tr>
      <td>Chon file 1: </td>
      <td><input name="f1" type="file" id="f1"></td>
    </tr>

	
    <tr>
      <td>&nbsp;</td>
      <td><input name="cmd" type="submit" id="cmd" value="Upload">
      <input type="reset" name="Reset" value="Reset"></td>
    </tr>
  </table>
</form> 
<?

	if ($_REQUEST["cmd"] =="Upload"){
		$a = $_FILES["f1"]["tmp_name"];
		$b = $_FILES["f1"]["name"];
		$c = $_FILES["f1"]["size"];
		$d = $_FILES["f1"]["type"];
		$e = $_FILES["f1"]["error"];
		
		 
		echo strstr("image",$d); 
		if (!getimagesize($_FILES['f1']['tmp_name']))
			{ echo "<font color=red><center>Invalid Image File...</center></font>";
			exit();
			}
			
			if (substr($d,0,5)=="image"){
				
		move_uploaded_file($a,"../img/oldproduct/".$b);
		echo "Đã upload thành công file <b>{$b}</b>!<br>Click vào ảnh để chọn file này.<br>";
		
		echo "<a title='Chọn file này' href=# onclick=\"window.opener.document.f1.slide3.value='$b'; window.opener.document.img.src='../img/oldproduct/$b';window.close();\"><img border=0 width=80 src=../img/oldproduct/".$b." height=60></a>";
		
 
		
		
		} else {
		echo "Upload không thành công!";
		}
	}
			break;
			
			case "chon-anh3":?>
			<h1 align="center">Chọn ảnh</h1>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<? 
$a = opendir("../img/oldproduct");
$i=0;
while($f=readdir($a)){
	
	if ($f!="." && $f!=".."){
		$b = substr($f,strlen($f)-3,3);
		
		if ($b=="jpg" || $b =="jpe" || $b=="gif" || $b=="bmp"){
		if ($i==0) echo "<tr>";
		$i++;
		echo "<td><a href=# onclick=\"window.opener.document.f1.slide3.value='$f'; window.opener.document.img.src='../img/oldproduct/$f'; window.close();\"><img border=0 width=80 src=../img/oldproduct/".$f." title='$f'>
			</a>
		</td>";
		
		
		if ($i==2) {echo "</tr>"; $i=0;}
		}
	}
}
?>
</table><?
			break;
			
	
	
	case "up-anh4":
	
	
?>




<form enctype="multipart/form-data" method="post">
 <div align="center">
   <h1>Upload file 
   </h1>
 </div>

 
 <table width="400" border="0" align="center" cellpadding="3" cellspacing="3">
    <tr>
      <td>Chon file 1: </td>
      <td><input name="f1" type="file" id="f1"></td>
    </tr>

	
    <tr>
      <td>&nbsp;</td>
      <td><input name="cmd" type="submit" id="cmd" value="Upload">
      <input type="reset" name="Reset" value="Reset"></td>
    </tr>
  </table>
</form> 
<?

	if ($_REQUEST["cmd"] =="Upload"){
		$a = $_FILES["f1"]["tmp_name"];
		$b = $_FILES["f1"]["name"];
		$c = $_FILES["f1"]["size"];
		$d = $_FILES["f1"]["type"];
		$e = $_FILES["f1"]["error"];
		
		 
		echo strstr("image",$d); 
		if (!getimagesize($_FILES['f1']['tmp_name']))
			{ echo "<font color=red><center>Invalid Image File...</center></font>";
			exit();
			}
			
			if (substr($d,0,5)=="image"){
				
		move_uploaded_file($a,"../img/oldproduct/".$b);
		echo "Đã upload thành công file <b>{$b}</b>!<br>Click vào ảnh để chọn file này.<br>";
		
		echo "<a title='Chọn file này' href=# onclick=\"window.opener.document.f1.slide4.value='$b'; window.opener.document.img.src='../img/oldproduct/$b';window.close();\"><img border=0 width=80 src=../img/oldproduct/".$b." height=60></a>";
		
 
		
		
		} else {
		echo "Upload không thành công!";
		}
	}
			break;
			
			case "chon-anh4":?>
			<h1 align="center">Chọn ảnh</h1>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<? 
$a = opendir("../img/oldproduct");
$i=0;
while($f=readdir($a)){
	
	if ($f!="." && $f!=".."){
		$b = substr($f,strlen($f)-3,3);
		
		if ($b=="jpg" || $b =="jpe" || $b=="gif" || $b=="bmp"){
		if ($i==0) echo "<tr>";
		$i++;
		echo "<td><a href=# onclick=\"window.opener.document.f1.slide4.value='$f'; window.opener.document.img.src='../img/oldproduct/$f'; window.close();\"><img border=0 width=80 src=../img/oldproduct/".$f." title='$f'>
			</a>
		</td>";
		
		
		if ($i==2) {echo "</tr>"; $i=0;}
		}
	}
}
?>
</table><?
			break;
				
	
	case "up-anh5":
	
	
?>




<form enctype="multipart/form-data" method="post">
 <div align="center">
   <h1>Upload file 
   </h1>
 </div>

 
 <table width="400" border="0" align="center" cellpadding="3" cellspacing="3">
    <tr>
      <td>Chon file 1: </td>
      <td><input name="f1" type="file" id="f1"></td>
    </tr>

	
    <tr>
      <td>&nbsp;</td>
      <td><input name="cmd" type="submit" id="cmd" value="Upload">
      <input type="reset" name="Reset" value="Reset"></td>
    </tr>
  </table>
</form> 
<?

	if ($_REQUEST["cmd"] =="Upload"){
		$a = $_FILES["f1"]["tmp_name"];
		$b = $_FILES["f1"]["name"];
		$c = $_FILES["f1"]["size"];
		$d = $_FILES["f1"]["type"];
		$e = $_FILES["f1"]["error"];
		
		 
		echo strstr("image",$d); 
		if (!getimagesize($_FILES['f1']['tmp_name']))
			{ echo "<font color=red><center>Invalid Image File...</center></font>";
			exit();
			}
			
			if (substr($d,0,5)=="image"){
				
		move_uploaded_file($a,"../img/product/".$b);
		echo "Đã upload thành công file <b>{$b}</b>!<br>Click vào ảnh để chọn file này.<br>";
		
		echo "<a title='Chọn file này' href=# onclick=\"window.opener.document.f1.anhnho.value='$b'; window.opener.document.img.src='../img/oldproduct/$b';window.close();\"><img border=0 width=80 src=../img/oldproduct/".$b." height=60></a>";
		
 
		
		
		} else {
		echo "Upload không thành công!";
		}
	}
			break;
			
			case "chon-anh5":?>
			<h1 align="center">Chọn ảnh</h1>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<? 
$a = opendir("../img/product");
$i=0;
while($f=readdir($a)){
	
	if ($f!="." && $f!=".."){
		$b = substr($f,strlen($f)-3,3);
		
		if ($b=="jpg" || $b =="jpe" || $b=="gif" || $b=="bmp"){
		if ($i==0) echo "<tr>";
		$i++;
		echo "<td><a href=# onclick=\"window.opener.document.f1.anhnho.value='$f'; window.opener.document.img.src='../img/oldproduct/$f'; window.close();\"><img border=0 width=80 src=../img/oldproduct/".$f." title='$f'>
			</a>
		</td>";
		
		
		if ($i==2) {echo "</tr>"; $i=0;}
		}
	}
}
?>
</table><?
			break;		

	}
	?>

